﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel.Description;
using BusinessModel.Services.Interfaces;
using BusinessModel;

namespace Annuaire.Web.Services.Behaviour
{
    [AttributeUsage(AttributeTargets.Method)]
    public class NGileadOperationBehavior : Attribute, IOperationBehavior
    {

        IUtility _Utils;
        public NGileadOperationBehavior()
        {
            _Utils = ServiceLocator.Get<IUtility>();
        }

        #region IOperationBehavior Members

        public void AddBindingParameters(OperationDescription operationDescription, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
        {
            // Nothing
        }

        public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
        {
            // Nothing
        }

        public void ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
        {
            dispatchOperation.Invoker = new NGileadOperationInvoker(dispatchOperation.Invoker, _Utils);
        }

        public void Validate(OperationDescription operationDescription)
        {
            // Nothing
        }

        #endregion
    }
}